// pages/Reward/Reward.js
const axios = require('../../utils/http.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    position: 0,
    money:0,
    proId:0,
    personInfos: [{
        refereeName: '金宜峰->金宜想->金磊->金鑫->金娟->金宜静',
        rewardinfo: [{
            img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1533128365558&di=5094cd6bfcb1527fa1dbd5b7a71ecbae&imgtype=0&src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2F9%2F573ac71de8c6c.jpg',
            monny: 100,
            name: '金宜峰',
          },
          {
            img: 'http://up.enterdesk.com/edpic_source/e8/1b/7d/e81b7d1110ab29270c52524e09a706f0.jpg',
            monny: 100,
            name: '金宜想',
          },
          {
            img: 'http://img5.imgtn.bdimg.com/it/u=2082340907,2919238696&fm=27&gp=0.jpg',
            monny: 100,
            name: '金磊',
          },
          {
            img: 'http://img.7xz.com/img/picimg/201609/20160907105336_593369dbbe9e2cc6534.jpg',
            monny: 100,
            name: '金鑫',
          },
          {
            img: 'http://pic1.win4000.com/wallpaper/2017-12-14/5a320da179ddc.jpg',
            monny: 100,
            name: '金娟',
          },
          {
            img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1533128365558&di=5094cd6bfcb1527fa1dbd5b7a71ecbae&imgtype=0&src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2F9%2F573ac71de8c6c.jpg',
            monny: 100,
            name: '金宜静',
          },
        ]
      },
      {
        refereeName: '金峰->金想->金静',
        rewardinfo: [{
            img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1533128365558&di=5094cd6bfcb1527fa1dbd5b7a71ecbae&imgtype=0&src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2F9%2F573ac71de8c6c.jpg',
            monny: 100,
            name: '金峰',
          },
          {
            img: 'http://up.enterdesk.com/edpic_source/e8/1b/7d/e81b7d1110ab29270c52524e09a706f0.jpg',
            monny: 100,
            name: '金想',
          },
          {
            img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1533128365558&di=5094cd6bfcb1527fa1dbd5b7a71ecbae&imgtype=0&src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2F9%2F573ac71de8c6c.jpg',
            monny: 100,
            name: '金静',
          },
        ]
      }, {
        refereeName: 'aa->bb->cc',
        rewardinfo: [{
            img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1533128365558&di=5094cd6bfcb1527fa1dbd5b7a71ecbae&imgtype=0&src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2F9%2F573ac71de8c6c.jpg',
            monny: 100,
            name: 'aa',
          },
          {
            img: 'http://up.enterdesk.com/edpic_source/e8/1b/7d/e81b7d1110ab29270c52524e09a706f0.jpg',
            monny: 100,
            name: 'bb',
          },
          {
            img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1533128365558&di=5094cd6bfcb1527fa1dbd5b7a71ecbae&imgtype=0&src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2F9%2F573ac71de8c6c.jpg',
            monny: 100,
            name: 'cc',
          },
        ]
      }
    ],
  },
  bindPickerChange: function(e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    var index = e.detail.value;
    this.setData({
      position: index
    })
  },
  personDetails: function(e) {
    wx.navigateTo({
      url: '../PersonMessage/PersonMessage'
    })
  },

  inputMnChange: function (e) {
    var moneynew = e.detail.value;
    this.setData({
      money: moneynew
    })
  },

  rewardClick: function(){
    this.rewardProjectHttp(this.data.proId)
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var moneynew = options.money
    this.data.proId = options.proId;
    console.log(options.money)
    this.setData({
      money: moneynew
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  },
  /*
  打赏
  */
  rewardProjectHttp: function (pro_id) {
    var parame = {
      pro_id: pro_id,
      reward_user_id:100,
      money:this.data.money,
      get_reward_user_id:101
    }
    console.log(parame);
    // axios.ti("成功", "success");
    axios.POST(true, 'Orders/order_reward', parame, function (res) {
      axios.ti("成功", "success");
      // wx.navigateBack({

      // })
    });
  }
})